<?	/*
	// File:	dnsmail.wcp.phps
	// Purpose:	named domain manipulation
	// Author:	Johan <webcp@100p100.net>
	*/

   
// domain mail system

// Handle domains manipulation
if ($type == "domain") {
	
	// TEMP: email adminmail for DNS
	$tmpdnsmsg = "
--------------------------------------------------

Needs DNS pointed to ".$data['ip']."
Host: ".$data['host']."
Domain: ".$data['domain']."
Aliases: ".$data['alias']."
Type: ".$data['type']."

http://".$data['host'].".".$data['domain']."

E-Mail Address: ".$data['email']."
Account ID: ".$data['id']."
MX Records are needed for: domain.com host.domain.com
";


	// Handle Domain Creation :: expect *
	if ($data['action'] == 'create') {
		
		// Send mail with "New Domain Created" title
		$tmpdnstitle = "New Domain Created on ".$cfg['sysname'];
		mail($cfg['adminmail'],$tmpdnstitle,$tmpdnstitle.$tmpdnsmsg,"From: webcp ".$cfg['webcp']." <".
			$data['email'].">\nReply-To: ".$data['email']."\n");
	}
	
	// Handle Domain updates :: expect *
	elseif ($data['action'] == 'update') {

		// Send mail with "New Updated Created" title
		// because of the changed serial #, compare domain name, host name and size of file.
		
		if ($data['host'] != $data['host1'] OR $data['domain'] != $data['domain1']){
			$tmpdnstitle = "Domain Updated on ".$cfg['sysname'];
			mail($cfg['adminmail'],$tmpdnstitle,$tmpdnstitle.$tmpdnsmsg,"From: webcp ".$cfg['webcp']." <".
				$data['email'].">\nReply-To: ".$data['email']."\n");
		}
	}
	
	// Remove Domain :: expect *
	elseif ($data['action'] == "remove") {
		if ($data['id'] AND file_exists($data['path'])) {
			// Send mail with "New Deleted Created" title
			$tmpdnstitle = "Domain Deleted on ".$cfg['sysname'];
			mail($cfg['adminmail'],$tmpdnstitle,$tmpdnstitle.$tmpdnsmsg,"From: webcp ".$cfg['webcp']." <".
				$data['email'].">\nReply-To: ".$data['email']."\n");
	 	}
	}
}

?>
